package com.fstec.ks.master.netty.receiver;

import org.springframework.beans.factory.annotation.Autowired;

import com.fstec.ks.master.MasterEngine;
import com.fstec.ks.master.bean.ExamRunInfo;
import com.fstec.ks.master.netty.ResponseMessageType;
import com.sinotn.gson.GsonFacade;
import com.sinotn.ks.definition.Computer;
import com.sinotn.ks.definition.Message;
import com.sinotn.ks.definition.MessageReceiver;
import com.sinotn.ks.netty.message.SimpleMessage;

/**
 * 考试服务器考试状态数据处理接口
 * @Title ExamInfoReceiver.java
 * @Package com.fstec.ks.master.netty.receiver
 * @Description 
 * Copyright: Copyright (c) 2023
 * Company:广东峰上科技有限公司
 * 
 * @author <a href="mailto:xieqj@fstec.com">谢启进</a>
 * @date 2023年10月13日 下午2:25:46
 * @version V1.0
 */
public class ExamInfoReceiver implements MessageReceiver {
	@Autowired
	private MasterEngine masterEngine;
	private int type=202;
	@Override
	public int getType() {
		return this.type;
	}

	public void setType(int type) {
		this.type = type;
	}

	@Override
	public void process(Computer computer, Message msg) {
		ExamRunInfo examRunInfo=GsonFacade.fromJson(msg.getText(), ExamRunInfo.class);
		masterEngine.updateExamInfo(computer.getRegKey(), examRunInfo);
		SimpleMessage sm=new SimpleMessage(ResponseMessageType.SUCCESS, msg.getToken());
		computer.sendMessage(sm);
	}

}
